Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 11: Grouping

../ch11/11fig01a.gif
Figure 11.1a

Three versions of a cafe sign within a Switch node with the whichChoice field set to 0. Compare with Figures 11.1b and c.

11fig01a.wrl
Click on the image to view the VRML scene.

#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Switch {
    whichChoice 0
    choice [
    # Version 0:  simple round background
        Group {
            children [
                DEF Cafe Shape {
                    appearance DEF GlowWhite Appearance {
                        material Material {
                            emissiveColor 1.0 1.0 1.0
                            diffuseColor  0.0 0.0 0.0
                        }
                    }
                    geometry Text {
                        string "Cafe"
                        fontStyle FontStyle {
                            justify "MIDDLE"
                        }
                    }
                },
                DEF BlueDisk Transform {
                    translation 0.0 0.3 -0.10
                    rotation    1.0 0.0 0.0 -1.57
                    children Shape {
                        appearance Appearance {
                            material Material {
                                diffuseColor  0.0 0.3 0.8
                            }
                        }
                        geometry Cylinder {
                            radius 1.3
                            height 0.1
                        }
                    }
                }
            ]
        },
    # Version 1:  round background with white edge
        Group {
            children [
                USE Cafe,
                USE BlueDisk,
                DEF WhiteDisk Transform {
                    translation 0.0 0.3 -0.10
                    rotation    1.0 0.0 0.0 -1.57
                    children Shape {
                        appearance USE GlowWhite
                        geometry Cylinder {
                            radius 1.4
                            height 0.08
                        }
                    }
                }
            ]
        },
    # Version 2:  round background, white edge, red box
        Group {
            children [
                USE Cafe,
                USE BlueDisk,
                USE WhiteDisk,
                DEF RedAndWhiteBoxes Transform {
                    translation 0.0 0.3 -0.10
                    children [
                        Shape {
                            appearance Appearance {
                                material Material {
                                    diffuseColor 0.8 0.0 0.0
                                }
                            }
                            geometry Box {
                                size 4.0 1.2 0.06
                            }
                        },
                        Shape {
                            appearance USE GlowWhite
                            geometry Box {
                                size 4.2 1.4 0.04
                            }
                        }
                    ]
                }
            ]
        }
    ]
}